<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>教室管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link href="__PUBLIC__/css/layui.css" rel="stylesheet" type="text/css"/>
    <link href="__PUBLIC__/css/admin.css" rel="stylesheet" type="text/css"/>
    <link href="__PUBLIC__/css/public.css" rel="stylesheet" type="text/css"/>
	
</head>
<body>
<div class="layui-conter">
    <div class="layui-col-md12">
        <div class="navigation">
            <span>教务></span><span>班级管理></span><span>教室管理</span>
        </div>

        <div class="white-conter">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="title-blue"><b>教室管理</b></div>
                    <div class="layui-card-body addPadding">
                        <form class="layui-form" action="{:U('Classsetting/classroomSet')}" lay-filter="component-form-group">
                            <div class=" layui-row" style="margin-top: 20px">
                                <div class=" layui-col-xs3" style="width: 28%;">
                                    <label class="layui-form-label">教室名称：</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="room_name_search" placeholder="请输入..." class="layui-input" >
                                    </div>
                                </div>
                                <div class="layui-inline search-1" style="margin-left: 20px;">
                                    <button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="" >搜索</button>
                                </div>
                            </div>
                        </form>
												<form class="layui-form" action="{:U('Classsetting/classroomSet')}" method="post" lay-filter="component-form-group">
														<div class=" layui-row" style="margin-top: 20px">
																<div class=" layui-col-xs3" style="width: 28%;">
																		<label class="layui-form-label">教室编号：</label>
																		<div class="layui-input-block">
																				<input type="text" name="roomnumber" placeholder="请输入..." class="layui-input" >
																		</div>
																</div>
																<div class=" layui-col-xs3" style="width: 28%;">
																		<label class="layui-form-label">教室名称：</label>
																		<div class="layui-input-block">
																				<input type="text" name="roomname" placeholder="请输入..." class="layui-input" >
																		</div>
																</div>
																<div class=" layui-col-xs3" style="width: 25%;">
																		<label class="layui-form-label">容纳人数：</label>
																		<div class="layui-input-block">
																			<input type="text" name="capacity" placeholder="请输入..." class="layui-input" >
																		</div>
																</div>
																<!--<div class=" layui-col-xs3" style="width: 28%;">
																		<label class="layui-form-label">所属校区：</label>
																		<div class="layui-input-block">
																				<select name="quiz3">
																						<option value="" selected="">请选择</option>
																						<option value="1">长宁校区</option>
																						<option value="2">虹口校区</option>
																				</select>
																		</div>
																</div>-->
																<div class="layui-inline add" style="margin-left: 20px;">
																	<button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="" >添加</button>
																</div>
														</div>
												</form>
                    </div>
                </div>
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-body"  style="border-bottom:none;">
                            <table  class="layui-hide" id="test-table-operate" lay-filter="test-table-operate"></table>
                            <div class="layui-form layui-border-box layui-table-view" lay-filter="LAY-table-1">
                                <div class="layui-table-box" style="margin-bottom: 20px">
                                    <div class="layui-table-body layui-table-main">
                                        <table cellspacing="0" cellpadding="0" border="0" class="layui-table">
                                            <thead>
                                            <tr>
                                                <th data-field="classNum" >
                                                    <div class="layui-table-cell laytable-cell-classNum">
                                                        <span>教室编号</span>
                                                    </div>
                                                </th>
                                                <th data-field="ac-name">
                                                    <div class="layui-table-cell laytable-cell-ac-name" align="center">
                                                        <span>教室名称</span>
                                                    </div>
                                                </th>
                                                <th data-field="ac-type">
                                                    <div class="layui-table-cell laytable-cell-ac-type" align="center">
                                                        <span>容纳人数</span>
                                                    </div>
                                                </th>
																								<th data-field="campus">
																									<div class="layui-table-cell laytable-cell-campus" align="center">
																										<span>所属校区</span>
																									</div>
																								</th>
                                                <th data-field="ac-state">
                                                    <div class="layui-table-cell laytable-cell-ac-state" align="center">
                                                        <span>状态</span>
                                                    </div>
                                                </th>
                                                <th data-field="operation">
                                                    <div class="layui-table-cell laytable-cell-1-operation" align="center">
                                                        <span>操作</span>
                                                    </div>
                                                </th>
                                            </tr>
                                            </thead>
                                            <tbody>
																						<foreach name="room_data" item="room">
																						<tr data-index="{$key+1}" class="">
																							<td data-field="ac-id"  align="center">
																								<div class="layui-table-cell laytable-cell-ac-id">{$room.roomnumber}</div>
																							</td>
																							<td data-field="ac-name" align="center">
																								<div class="layui-table-cell laytable-cell-ac-name">{$room.roomname}</div>
																							</td>
																							<td data-field="ac-type" align="center">
																								<div class="layui-table-cell laytable-cell-ac-type">{$room.capacity}</div>
																							</td>
																							<td data-field="campus" align="center">
																								<div class="layui-table-cell laytable-cell-campus">
																								{$room.x_name}
																								</div>
																							</td>
																							<td data-field="ac-state" align="center">
																								<div class="layui-table-cell laytable-cell-ac-state">
																									<if condition="$room['state'] eq 0">关闭
																									<else/>
																									启用
																									</if>
																								</div>
																							</td>
																							<td data-field="operation" align="center">
																								<div class="layui-table-cell laytable-cell-1-operation">
																									<button data-method="offset" data-type="auto" data-id="{$room.id}" class="img-but edit-img"></button>
																									<button data-method="offset" data-type="auto"  onclick="room_del('room',{$room.id})" class="img-but del-img"></button>
																								</div>
																							</td>
																						</tr>
																						</foreach>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                                
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>


    </div>
</div>
</body>
<script src="__PUBLIC__/js/layui.all.js"></script>
<script src="__PUBLIC__/js/jquery.js"></script>
<script>
    layui.use(['form','layer','laydate','element'], function(){
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#datesign' //指定元素
        });
				var  form = layui.form
						, $ = layui.jquery
						,layer = layui.layer
						,element = layui.element
						, laydate = layui.laydate;
				element.render();
				//触发事件
								var active = {
										offset: function(othis){
												var type = othis.data('type')
														,text = othis.text();
												layer.open({
														type: 1,
														title: false,
														area: ['600px', '400px'],
														shadeClose: true,
														skin: 'layer-look',
														content:'<form class="layui-form layer_notice"  action="{:U("Classsetting/roomedit")}" method="post" lay-filter="test1" >' +
														'</form>'
												});
				
										}
								};
								$('.edit-img').on('click', function(){
										var othis = $(this), method = othis.data('method'),id = othis.data('id');
										active[method] ? active[method].call(this, othis) : '';
										$.post("{:U('Classsetting/roomsearch')}",{id:id},function(data){
										//	console.log(data);
											var html= '<div class="layui-col-md12 msgCont">' +
													'<div class="layui-col-md6">' +
													'<input type="hidden" name="id" value="'+data.id+'">' +
													'<div class="listTop"><div class="layui-col-md5">教室编号</div><div class="layui-col-md6">  <input type="text" name="roomnumber" value="'+data.roomnumber+'" class="layui-input" ></div></div>' +
													'<div class="listTop"><div class="layui-col-md5">教室名称</div><div class="layui-col-md6">  <input type="text" name="roomname" value="'+data.roomname+'" class="layui-input" ></div></div>' +
													'<div class="listTop"><div class="layui-col-md5">容纳人数</div><div class="layui-col-md6">  <input type="text" name="capacity" value="'+data.capacity+'" class="layui-input" ></div></div>' +
													'<div class="listTop"><div class="layui-col-md5">所属校区</div><div class="layui-col-md6">'+data.xname+'</div></div>' +
													'<div class="listTop"><div class="layui-col-md5">状态</div>' +
													'<div class="layui-col-md7">' +
													'<select name="state" style="display: block"> ' +
													'<option value="0">关闭</option>' +
													' <option value="1">开启</option>' +
													'</select>' +
													'</div>' +
													'</div>' +
													'</div>  <div class="layui-col-md12">\n' +
													'                            <div class="button-block">\n' +
													'                                <button class="layui-btn layui-btn-xs layui-btn-normal" lay-submit="" onclick="save()">保存</button>\n' +
													'                            </div>\n' +
													'                        </div>' +
													'</div>'
											$('.layer_notice').append(html);
											
											//执行一个laydate实例
											laydate.render({
													elem: '#start_time' //指定元素
											});
											laydate.render({
													elem: '#next_time' //指定元素
											});
										})
								});
    });
function room_del(model,id){
	$.post("{:U('Index/del')}",{model:model,id:id},function(data){
		if(data==1){
			alert('删除成功!');
			window.location.href="{:U('Classsetting/classroomSet')}";
		}else{
			alert('删除失败');
		}
	})
}
</script>
</html>